package com.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MsgController {

    /* 发送kafka */
    @Autowired
    @SuppressWarnings("all")
    private KafkaTemplate<String, String> kafkaTemplate;

    @GetMapping("sendK")
    public String send(){
        // kafkaTemplate.send(消息名称,消息数据) // 向kafka发送消息
        // token~用户ID~用户点击商品ID~商品类别ID~操作时间
        String log = "zasdad~1~46~23~2021-04-15 09:04:00";
        kafkaTemplate.send("streaming",log);

        return "SUCCESS";
    }

}
